package com.brayan.webapp.controller;

import java.io.Serializable;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.inject.Inject;

import com.brayan.webapp.model.PubCategory;
import com.brayan.webapp.repository.PubCategoryRepository;

@ManagedBean
@RequestScoped
public class CategoryTileController implements Serializable {

	private static final long serialVersionUID = 6555461789692254085L;

	@Inject
	private PubCategoryRepository pubCategoryRepository;

	private List<PubCategory> listOfCategories;
	
	/**
	 * Load all categories while loading.
	 */
	@PostConstruct
	private void init(){
		setListOfCategories(pubCategoryRepository.getAllActivePubCategories());
	}

	public List<PubCategory> getListOfCategories() {
		return listOfCategories;
	}

	public void setListOfCategories(List<PubCategory> listOfCategories) {
		this.listOfCategories = listOfCategories;
	}
}
